package at.com.vn.chess.entity;

import javax.xml.bind.annotation.XmlRootElement;

import at.com.vn.chess.util.CommonMethod;
import at.com.vn.chess.util.Const;

@XmlRootElement
public class PlayersInfo implements Entity {
	
	private String processName;
	private int rId;
	private int tId;

	private String player1Name;
	private String player2Name;
	private int whosWon;
	private boolean isOwnerAct;

	public PlayersInfo() {
		super();
		player1Name = "";
		player2Name = "";
		whosWon = Const.UNDEFINE_VALUE;
		isOwnerAct = false;
	}

	public PlayersInfo( int roomId, int tableId, String player1Name,
			String player2Name, boolean isTablesOwner ) {
		this.rId = roomId;
		this.tId = tableId;
		this.player1Name = player1Name;
		this.player2Name = player2Name;
		whosWon = Const.UNDEFINE_VALUE;
		isOwnerAct = isTablesOwner;
	}
	public String getPlayer1Name() {
		return player1Name;
	}
	public void setPlayer1Name( String player1Name ) {
		this.player1Name = player1Name;
	}
	public String getPlayer2Name() {
		return player2Name;
	}
	public void setPlayer2Name( String player2Name ) {
		this.player2Name = player2Name;
	}

	public boolean getIsOwnerAct() {
		return isOwnerAct;
	}

	public void setIsOwnerAct(boolean isOwnerAct) {
		this.isOwnerAct = isOwnerAct;
	}

	public int getWhosWon() {
		return whosWon;
	}

	public void setWhosWon(int whosWon) {
		this.whosWon = whosWon;
	}

//	public static void main(String[] args) {
//		PlayersInfo info =  new PlayersInfo();
//		info.setPlayer1Name("nghi");
//		info.setPlayer2Name("nhai");
//		System.out.println(XmlUtils.convertToXml(info, "processName"));
//	}

	@Override
	public String getProcessName() {
		return processName;
	}

	@Override
	public void setProcessName(String processName) {
		this.processName = processName;
		
	}

	@Override
	public boolean isOwnTable(int room, int table) {		
		return rId == room && tId == table;
	}

	@Override
	public String getBoardsKey() {		
		return CommonMethod.createBoardKey(rId, tId);
	}

	public int getRId() {
		return rId;
	}

	public void setRId(int rId) {
		this.rId = rId;
	}

	public int getTId() {
		return tId;
	}

	public void setTId(int tId) {
		this.tId = tId;
	}
}
